package com.wawayaya.db.entitydao;


import android.util.Log;

import com.wawayaya.bean.Banner;
import com.wawayaya.db.DBManager;
import com.wawayaya.db.basedao.BannerDao;

public class BannerEntityDao extends BaseEntityDao<BannerDao, Banner, Long> {

	@Override
	protected BannerDao initEntityDao() {
		return DBManager.newSession().getBannerDao();
	}

	public void deleteEntityByKey(Long key) {
		getEntityDao().deleteByKey(key);
	}

	@Override
	public void replaceEntity(Banner entity) {
		getEntityDao().insertOrReplace(entity);
	}

	@Override
	public Banner queryEntityByWhere(String where, String... selectionArg) {
		return super.queryEntityByWhere(where, selectionArg);
	}

	public  void  insertOrReplaceByWhere(Banner  entiviy){
		boolean  flag =  queryByEntity(" where BANNER_ID = ?",String.valueOf(entiviy.getBannerId()));
		Log.e("flag......","flag........"+flag);
		  if(!flag){
			   replaceEntity(entiviy);
		  }
	}
}
